package name.jiaosha.air.company.controller;

import java.util.List;

import name.jiaosha.air.OperateTip;
import name.jiaosha.air.company.domain.Company;
import name.jiaosha.air.company.domain.Storage;
import name.jiaosha.air.company.service.ICompanyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("storageController")
public class StorageController {
	@Autowired
	private ICompanyService companyService;

	public OperateTip create(Storage storage) {

		Company company = companyService.getCompanyById(1);
		storage.setCompany(company);
		companyService.createStorage(storage);
		OperateTip tip = new OperateTip("1", "操作成功");
		return tip;
	}

	public OperateTip update(Storage storage) {

		Storage s = companyService.getStorageById(storage.getId());

		s.setName(storage.getName());
		companyService.updateStorage(storage);
		OperateTip tip = new OperateTip("1", "操作成功");
		return tip;
	}

	public Storage getStorageById(int id) {
		Storage storage=companyService.getStorageById(id);
		storage.getStorageSpaces();
		return storage;
	}

	public List<Storage> getMyStorageList() {

		return companyService.getStorageByComId(1);
	}

}
